package ar.edu.unq.wannaplay.utils;

import java.io.Serializable;
import java.util.Date;

import org.joda.time.DateTime;
import org.joda.time.Interval;
import org.joda.time.LocalDate;

public class DateCollector implements Serializable {

    private static final long serialVersionUID = 1L;

    private Date start = new Date();

    private Date end = new Date();

    public void setEnd(final Date to) {
        end = to;
    }

    public Date getEnd() {
        return end;
    }

    public void setStart(final Date from) {
        start = from;
    }

    public Date getStart() {
        return start;
    }

    private DateTime getDateTime(final Date date) {
        // tener que hacer esto es una poronga!
        LocalDate local = new LocalDate(date.getYear() + 1900, date.getMonth() + 1, date.getDate());
        return local.toDateTimeAtStartOfDay();
    }

    public DateTime getStartDateTime() {
        return this.getDateTime(this.getStart());
    }

    public DateTime getEndDateTime() {
        return this.getDateTime(this.getEnd());

    }

    public Interval toInterval() {
        return new Interval(this.getStartDateTime(), this.getEndDateTime());
    }

}
